package bocchi.card;

import bocchi.base.BaseCustomCard;
import bocchi.BocchiCore;
import com.evacipated.cardcrawl.mod.stslib.actions.common.SelectCardsAction;
import com.megacrit.cardcrawl.actions.common.DrawCardAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.monsters.AbstractMonster;

import java.util.LinkedList;

public class BocchiTheRock extends BaseCustomCard {
    private static final String RAW_ID = BocchiTheRock.class.getSimpleName();
    public static final String GAME_ID = BocchiCore.getGameID(RAW_ID);

    public BocchiTheRock() {
        super(RAW_ID);
    }

    @Override
    public void use(AbstractPlayer player, AbstractMonster monster) {
        String text = String.format("选择%d张牌", magicNumber);
        addToBot(new SelectCardsAction(player.drawPile.group, magicNumber, text, true, card -> true, cards -> {
            LinkedList<AbstractCard> toDiscard = new LinkedList<>();

            for (AbstractCard card : player.drawPile.group) {
                if (!cards.contains(card)) {
                    toDiscard.add(card);
                }
            }

            for (AbstractCard card : toDiscard) {
                player.drawPile.moveToDiscardPile(card);
            }
        }));

        addToBot(new DrawCardAction(2));
    }
}
